/**
 * 主通用文件
 */
// 引入 swiper文件
import Swiper from '../common/swiper/swiper-bundle.esm.browser.min.js';



// 初始化 swiper
new Swiper('.swiper', {
  loop: true, // 循环衔接
  speed: 1000, // 切换速度
  height: 600, //你的slide高度
  clickable: true, // 可点击
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
  pagination: {
    el: '.swiper-pagination',
  },
  on: {
    slideChangeTransitionEnd: function () {
      // 获取当前滑块的索引,更改对应指示器的样式
      let index = this.activeIndex;
      let pagination = this.el.querySelector('.swiper-pagination');
      // console.log(pagination);
      // alert(this.activeIndex); //切换结束时，告诉我现在是第几个slide
    },
  },
});

var swiper = new Swiper(".mySwiper", {
  loop: true,
  speed: 2000,
  autoplay: true,
  autoplay: {
    delay: 2000,
    disableOnInteraction: false
  },
  slidesPerView:4,
  spaceBetween: 30,
  freeMode: true,
  pagination: {
    el: ".swiper-pagination",
    clickable: true,
  },
});





/* 经典案例-鼠标移入停止轮播 */
swiper.el.onmouseover = function() { 
  //鼠标放上暂停轮播
  swiper.autoplay.stop();
}
swiper.el.onmouseleave = function() {
  swiper.autoplay.start();
}
// 开发流程
// app案例

